//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_dismissallbuttonaction.sqf"
#include "x_setup.sqf"

#include "x_uiinc.sqf"

if (__pGetVar(GVAR(recdbusy))) exitWith {};
__pSetVar [QGVAR(recdbusy), true];
private ["_control2", "_ctrl", "_control"];
_has_ai = false;
{
	if (!isPlayer _x) then {
		_has_ai = true;
		if (vehicle _x == _x) then {
			deleteVehicle _x;
		} else {
			moveOut _x;
			[_x] spawn {
				scriptName "spawn_d_fnc_dismissallbuttonaction_waitvec";
				PARAMS_1(_unit);
				waitUntil {sleep 0.212;vehicle _unit == _unit};
				deleteVehicle _unit;
			};
		};
	};
} forEach units group player;
if (_has_ai) then {(localize "STR_DOM_MISSIONSTRING_216") call FUNC(HQChat)};
(__uiGetVar(GVAR(RECRUIT_DIALOG)) displayCtrl 1011) ctrlShow false;
(__uiGetVar(GVAR(RECRUIT_DIALOG)) displayCtrl 1012) ctrlShow false;
GVAR(current_ai_num) = 0;

_control2 = __uiGetVar(GVAR(RECRUIT_DIALOG)) displayCtrl 1030;
_control2 ctrlSetText format [(localize "STR_DOM_MISSIONSTRING_693"), GVAR(current_ai_num), GVAR(max_ai)];

_ctrl = __uiGetVar(GVAR(RECRUIT_DIALOG)) displayCtrl 1010;
if (!ctrlShown _ctrl) then {
	_ctrl ctrlShow true;
};

_control = __uiGetVar(GVAR(RECRUIT_DIALOG)) displayCtrl 1001;
lbClear _control;

GVAR(current_ai_units) = [];
__pSetVar [QGVAR(recdbusy), false];